<template>
	<view>
		<view style="background-color: #fff;position: relative;padding-left: 150upx;height: 200upx;margin: 20upx;border-radius: 20upx;">
			<view style="position: absolute;top: 60upx;left: 30upx;">
				<image style="width: 80upx;height: 80upx;" src="../../../static/Adress.png" mode=""></image>
			</view>
			<view style="display: flex;">
				<view style="line-height: 150upx;">
					{{name}}
				</view>
				<view style="line-height: 150upx;margin-left: 30upx;">
					{{mobile}}
				</view>
			</view>
			<view style="margin-top: -40upx;">
				{{province_name}}{{city_name}}{{district_name}}{{address}}
			</view>
		</view>
		<view style="background-color: #fff;position: relative;margin: 20upx;border-radius: 20upx;padding: 30upx;">
			<view v-if="id != 0" v-for="(item,index) in orderGoods" :key="index" style="display: flex;justify-content: space-around;height: 170upx;border-bottom: 1upx solid #E5E5E5;">
				<view >
					<image style="width: 150upx;height: 150upx;" :src="item.goods_thumb_image" mode=""></image>
				</view>
				<view>
					<view style="line-height: 100upx;">
						{{item.goods_name}}
					</view>
					<view style="margin-top: -20upx;color: #7F7F7F;">
						{{item.format}}
					</view>
				</view>
				<view style="line-height: 150upx;">
					X{{item.number}}
				</view>
				<view>
					<view style="line-height: 100upx;">
						¥{{item.turnover_price}}
					</view>
					<view style="margin-top: -20upx;color: #7F7F7F;">
						¥{{item.cost_price}}
					</view>
				</view>
			</view>
			<view v-if="limitTime_id != 0" style="display: flex;justify-content: space-around;height: 170upx;border-bottom: 1upx solid #E5E5E5;">
				<view >
					<image style="width: 150upx;height: 150upx;" :src="goods_thumb_image" mode=""></image>
				</view>
				<view>
					<view style="line-height: 100upx;">
						{{goods_name}}
					</view>
					<view style="margin-top: -20upx;color: #7F7F7F;">
						{{format}}
					</view>
				</view>
				<view style="line-height: 150upx;">
					X{{number}}
				</view>
				<view>
					<view style="line-height: 100upx;">
						¥{{pay_price}}
					</view>
					<view style="margin-top: -20upx;color: #7F7F7F;">
						¥{{cost_price}}
					</view>
				</view>
			</view>
			<view style="display: flex;justify-content: space-between;height: 70upx;line-height: 70upx;margin-top: 30upx;">
				<view >
					产品金额
				</view>
				<view >
					¥{{pay_price}}
				</view>
			</view>
			<view style="display: flex;justify-content: space-between;height: 70upx;line-height: 70upx;">
				<view >
					优惠券
				</view>
				<view>
					-¥{{coupon_price}}
				</view>
			</view><view style="display: flex;justify-content: space-between;height: 70upx;line-height: 70upx;">
				<view >
					运费
				</view>
				<view >
					¥0
				</view>
			</view>
			<view style="display: flex;justify-content: space-between;height: 70upx;line-height: 70upx;">
				<view >
					支付方式
				</view>
				<view v-show="pay_type == 1">奖金余额</view>
				<view v-show="pay_type == 3">微信</view>
				<view v-show="pay_type == 4">首单余额</view>
			</view>
			<view style="display: flex;justify-content: space-between;height: 70upx;line-height: 70upx;">
				<view >
					总计
				</view>
				<view >
					¥{{pay_price}}
				</view>
			</view>
		</view>
		<view style="background-color: #fff;position: relative;height: 100upx;margin: 20upx 20upx 0;border-radius: 20upx 20upx 0 0;padding: 30upx;" @click="hide_" v-show="tax_id != 0">
			<view style="display: flex;justify-content: space-between;height: 70upx;line-height: 70upx;">
				<view >发票信息</view>
				<view  style="color: #7F7F7F;"> > </view>
			</view>
		</view>
		<view style="background-color: #fff;position: relative;border-radius: 0 0 20upx 20upx;margin: 0 20upx;" :style="{display: show_hide}">
			<view style="height: 100upx;margin: 0 30upx;display: flex;">
				<view style="flex: 5;">银行</view><view style="flex: 4;text-align: right;">{{taxInfo.bank}}</view>
			</view>
			<view style="height: 100upx;margin: 0 30upx;display: flex;">
				<view style="flex: 5;">银行卡号</view><view style="flex: 4;text-align: right;">{{taxInfo.bankNumber}}</view>
			</view>
			<view style="height: 100upx;margin: 0 30upx;display: flex;">
				<view style="flex: 5;">公司地址</view><view style="flex: 4;text-align: right;">{{taxInfo.company_address}}</view>
			</view>
			<view style="height: 100upx;margin: 0 30upx;display: flex;">
				<view style="flex: 5;">公司名</view><view style="flex: 4;text-align: right;">{{taxInfo.company_name}}</view>
			</view>
			<view style="height: 100upx;margin: 0 30upx;display: flex;">
				<view style="flex: 5;">公司电话</view><view style="flex: 4;text-align: right;">{{taxInfo.company_phone}}</view>
			</view>
		</view>
	</view>
</template>
<script>
	export default{
		data(){
			return{
				id:0,
				user_id:'',
				order_id:'',
				name:'',
				mobile:'',
				province_name:'',
				city_name :'',
				district_name :'',
				address :'',
				orderGoods:'',
				pay_price:'',
				tax_id:'',
				limitTime_id:0,
				coupon_price:0,
				taxInfo:{},// 发票信息
				show_hide: 'none',
				pay_type:'',
			}
		},
		onLoad(e) {
			let eee = e
			uni.getStorage({
				key: 'user_id',
				success: (res) => {
					this.user_id = res.data
					
					if(eee.id){
						this.order_id = eee.id
						this.getdata()
					}
					if(eee.group_id){
						this.order_id = eee.group_id
						this.getdata1()
					}
					if(eee.limitTime_id){
						this.order_id = eee.limitTime_id
						this.getdata2()
					}
				}
			});
			
			
		},
		methods:{
			getdata(){
				// 普通订单详情
				uni.request({
					url:'https://cx.mingmeijt.com/Api/Order/orderDetail',
					method:'POST',
					data:{
						user_id:this.user_id,
						order_id:this.order_id,
						session_id: uni.getStorageSync("sessionid")
					},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: (res) => {
						console.log(res)
						if(res.data.code == 999){
							uni.navigateTo({
								url:'/pages/999/999'
							})
						};
						if(res.data.code == 998){
							uni.navigateTo({
								url:'/pages/login/login'
							})
						}
						this.name = res.data.data.addressInfo.name
						this.mobile = res.data.data.addressInfo.mobile
						this.province_name = res.data.data.addressInfo.province_name
						this.city_name = res.data.data.addressInfo.city_name
						this.district_name = res.data.data.addressInfo.district_name
						this.address = res.data.data.addressInfo.address
						
						this.pay_price = res.data.data.orderInfo.pay_price
						this.pay_type = res.data.data.orderInfo.pay_type
						this.coupon_price = res.data.data.orderInfo.coupon_price
						if(res.data.data.orderGoods) {
							this.orderGoods = res.data.data.orderGoods
							for(var i = 0; i <this.orderGoods.length; i++) {
								this.orderGoods[i].goods_thumb_image = 'https://cx.mingmeijt.com' + this.orderGoods[i].goods_thumb_image
								// console.log(this.orderGoods[i].goods_thumb_image)
							}
						}
						
						// 发票信息展示
						this.tax_id = res.data.data.orderInfo.tax_id
						if (res.data.data.orderInfo.tax_id != 0) { // 等于0代表没有发票信息就是 个人
							this.taxInfo = res.data.data.taxInfo
						}
						
					}
				})
			},
			getdata1(){
				// 拼团订单详情
				uni.request({
					url:'https://cx.mingmeijt.com/Api/AssembleOrder/orderDetail',
					method:'POST',
					data:{
						user_id:this.user_id,
						order_id:this.order_id,
						session_id: uni.getStorageSync("sessionid")
					},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: (res) => {
						console.log(res)
						this.name = res.data.data.addressInfo.name
						this.mobile = res.data.data.addressInfo.mobile
						this.province_name = res.data.data.addressInfo.province_name
						this.city_name = res.data.data.addressInfo.city_name
						this.district_name = res.data.data.addressInfo.district_name
						this.address = res.data.data.addressInfo.address
						
						this.pay_price = res.data.data.orderInfo.pay_price
						this.pay_type = res.data.data.orderInfo.pay_type
						
						if (res.data.data.orderGoods) {
							this.orderGoods = res.data.data.orderGoods
							for(var i = 0; i<this.orderGoods.length; i++) {
									this.orderGoods[i].goods_thumb_image = 'https://cx.mingmeijt.com' + this.orderGoods[i].goods_thumb_image
									console.log(this.orderGoods[i].goods_thumb_image)
								}
						}
						
						// 发票信息展示
						this.tax_id = res.data.data.orderInfo.tax_id
						if (res.data.data.orderInfo.tax_id != 0) { // 等于0代表没有发票信息就是 个人
							this.taxInfo = res.data.data.taxInfo
						}
					}
				})
			},
			getdata2(){
				// 抢购订单详情
				uni.request({
					url:'https://cx.mingmeijt.com/Api/PanicBuyingOrder/orderDetail',
					method:'POST',
					data:{
						user_id:this.user_id,
						order_id:this.order_id,
						session_id: uni.getStorageSync("sessionid")
					},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: (res) => {
						console.log(res)
						this.name = res.data.data.addressInfo.name
						this.mobile = res.data.data.addressInfo.mobile
						this.province_name = res.data.data.addressInfo.province_name
						this.city_name = res.data.data.addressInfo.city_name
						this.district_name = res.data.data.addressInfo.district_name
						this.address = res.data.data.addressInfo.address
						
						this.pay_price = res.data.data.orderInfo.pay_price
						this.pay_type = res.data.data.orderInfo.pay_type
						this.goods_thumb_image = 'https://cx.mingmeijt.com' + res.data.data.orderInfo.goods_thumb_image
						this.format = res.data.data.orderInfo.format
						this.goods_name = res.data.data.orderInfo.goods_name
						this.number = res.data.data.orderInfo.number
						this.pay_price = res.data.data.orderInfo.pay_price
						this.cost_price = res.data.data.orderInfo.cost_price
						
						// 发票信息展示
						this.tax_id = res.data.data.orderInfo.tax_id
						if (res.data.data.orderInfo.tax_id != 0) { // 等于0代表没有发票信息就是 个人
							this.taxInfo = res.data.data.taxInfo
						}
					}
				})
			},
			hide_ () {
				if (this.show_hide == 'block') {
					this.show_hide = 'none'
					return
				} 
				if (this.show_hide == 'none') {
					this.show_hide = 'block'
					return
				}
				
				// this.show_hide == 'block' ? 'none' : 'block'
			}
		}
	}
</script>